With regard to computers, garbage collection refers to a process of identifying unused areas of main memory storage. In accordance with an object oriented computing language, the computer executing the program allocates memory for each of the objects. Memory is allocated to, and freed from, the heap in blocks of one of a number of predetermined sizes. Eventually, when the objects are no longer being referenced by the program, the memory allocated for the created objects is reclaimed through a garbage collection process. The garbage collection process clears the objects from memory whereby the once allocated memory is again available for use. More particularly, a garbage collection process involves automatically determining which blocks of memory can be freed, marking unused blocks as no longer needed by an application, collecting all of the unused blocks of memory at periodic intervals, returning the unused blocks to the heap and marking the blocks as free for use. Such a garbage collection process is often referred to as a mark-and-sweep since unused portions of memory are marked as garbage during a mark phase and then removed from allocated memory in a sweep phase. Although the process of garbage collection frees memory, it may be problematic in applications where its unpredictable consumption of processor time affects the running of the application.
Read barrier is a term of art that describes a special check performed each time application code fetches a value from a heap memory location. The read barrier serves to coordinate the application processing with the garbage collection. The read barrier checks each pointer reference to verify that the object accessed through the pointer is not being moved. Unfortunately, high software and processing overhead costs are typically associated with prior art read barriers and they are often considered inappropriate for real-time systems. In addition, the implementation of the read barrier introduces time consuming required null-checks. Therefore, what is needed is an improved read barrier that can be optimized to reduce its associated overhead and used with a real-time application.